
using System;

namespace raycsharp
{


	public class Camera
	{
		public Observer observer { get; set; }
		public Grid grid { get; set; }
		
		public Camera (Observer _observer, Grid _grid) {
			observer = _observer;
			grid = _grid;
			
			Vector Y = observer.up.normalize();
			Vector Z = (grid.position - observer.position).normalize();
			Vector X = Y.cross_product(Z);
			
			grid.x = X;
			grid.y = Y;
			grid.z = Z;
			
		}
		
		public Ray generate_ray(uint _x, uint _y) {
			Vector direction = grid.position - observer.position + (grid.projection_transformation(_x,_y));
			return new Ray(observer.position,direction.normalize());
		}
	}
}
